-- following options are the default
-- each of these are documented in `:help nvim-tree.OPTION_NAME`
vim.g.nvim_tree_icons = {
  default = "",
  symlink = "",
  git = {
    unstaged = "",
    staged = "S",
    unmerged = "",
    renamed = "➜",
    deleted = "",
    untracked = "U",
    ignored = "◌",
  },
  folder = {
    default = "",
    open = "",
    empty = "",
    empty_open = "",
    symlink = "",
  },
}

local status_ok, nvim_tree = pcall(require, "nvim-tree")
if not status_ok then
    vim.notify("nvim-tree not found.")
    return
end

local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
if not config_status_ok then
  return
end

local tree_cb = nvim_tree_config.nvim_tree_callback

local keymap_list = require("user.keymaps").nvimTreeList

nvim_tree.setup {
    disable_netrw = true,
    hijack_netrw = true,
    open_on_setup = false,
    open_on_setup_file = false,
    ignore_buffer_on_setup = false,
    ignore_ft_on_setup = {
        "startify",
        "dashboard",
        "alpha",
    },
    auto_reload_on_write = true,
    open_on_tab = false,
    sort_by = "name",
    hijack_unnamed_buffer_when_opening = false,
    hijack_directories = {
        enable = true,
        auto_open = true,
    },
    hijack_cursor = false,
    update_cwd = true,
    update_focused_file = {
        enable = true,
        update_cwd = true,
        ignore_list = {},
    },
    system_open = {
        cmd = nil,
        args = {},
    },
    diagnostics = {
        enable = true,
        show_on_dirs = false,
        icons = {
            hint = "",
            info = "",
            warning = "",
            error = "",
        },
    },
    git = {
        enable = true,
        ignore = true,
        timeout = 500,
    },
    view = {
        hide_root_folder = false,
        width = 30,
        height = 30,
        side = "left",
        number = false,
        relativenumber = false,
        mappings = {
            custom_only = false,
            list = keymap_list,
            -- list = {
            --     { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
            --     { key = "h", cb = tree_cb "close_node" },
            --     { key = "v", cb = tree_cb "vsplit" },
            -- },
        },
    },
    -- 隐藏文件
    filters = {
        dotfiles = false, -- .开头的文件
        custom = {},
    },
    trash = {
        cmd = "trash",
        require_confirm = true,
    },
    -- show_icons = {
    --     git = 1,
    --     folders = 1,
    --     files = 1,
    --     folder_arrows = 1,
    --     tree_width = 30,
    -- },
}
